package com.py.credit.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.py.credit.common.ServiceException;
import com.py.credit.dao.AuthorizonLogDao;
import com.py.credit.entity.AuthorizonLog;
import com.py.credit.service.AuthorizationLogService;
import com.py.credit.utils.SQLBuilder;
import com.py.framework.core.common.Page;

@Service
public class AuthorizationLogServiceImpl implements AuthorizationLogService {

	@Autowired
	private AuthorizonLogDao authorizonLogDao;

	@Override
	public List<Map<String, Object>> getByConditionForPage(List<String> showColumns, String[] additionalColumns,
			String condition, Page page) {
		if (CollectionUtils.isEmpty(showColumns)) {

			throw new ServiceException("至少选择一列导出");

		}
		List<String> conditions = SQLBuilder.createConditionSql(condition);

		return authorizonLogDao.selectByConditionForPage(showColumns, additionalColumns, conditions, page);
	}

	@Override
	public AuthorizonLog getBy(int id) {

		return authorizonLogDao.selectByPrimaryKey(id);
	}
}
